<!DOCTYPE HTML>
<html lang="fr">
<head>
	<title><?php echo CHtml::encode($this->pageTitle); ?></title>

	<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

	<!-- Bootstrap -->
	<link href="<?php echo Yii::app()->request->baseUrl; ?>/css/bootstrap<?php echo (($this->skin <> '') ? "-".$this->skin : "");?>.min.css" rel="stylesheet" media="screen">
	<link href="<?php echo Yii::app()->request->baseUrl; ?>/css/bootstrap-datepicker.css" rel="stylesheet" media="screen">

	<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
	<!--[if lt IE 9]>
	<script src="../../assets/js/html5shiv.js"></script>
	<script src="../../assets/js/respond.min.js"></script>
	<![endif]-->
	<link href="<?php echo Yii::app()->request->baseUrl; ?>/css/selavenir.css" rel="stylesheet" media="screen">
</head>

<body>

	<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
		<div class="container">
			<!-- Brand and toggle get grouped for better mobile display -->
			<div class="navbar-header">
				<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
					<span class="sr-only">Toggle navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="#">MySEL</a>
			</div>

			<!-- Collect the nav links, forms, and other content for toggling -->
			<div class="collapse navbar-collapse navbar-ex1-collapse">
				<ul class="nav navbar-nav">
					<?php if (!Yii::app()->user->isGuest) {?>
						<?php 
						if (Yii::app()->user->admin_seliste) {
							$actions_selistes = array("seliste/view","seliste/create","seliste/admin","seliste/liste","seliste/update_pass","seliste/update","seliste/update_grains");
							echo "<li class=\"dropdown";
							if (in_array($this->route,$actions_selistes)) echo " active";
							echo "\"\>";
							?>
								<a href="#" class="dropdown-toggle" data-toggle="dropdown">Sélistes <b class="caret"></b></a>
								<ul class="dropdown-menu">
									<?php
									echo "<li" . (($this->route == "seliste/create") ? " class='active'>" : ">") . CHtml::link('<span class="glyphicon glyphicon-plus-sign"></span> Ajouter un séliste',array('seliste/create')) . "</li>";
									echo "<li" . (($this->route == "seliste/admin") ? " class='active'>" : ">") . CHtml::link('<span class="glyphicon glyphicon-list"></span> Liste des sélistes',array('seliste/admin')) . "</li>";
									?>
								</ul>
							</li>
						<?php } else {?>
						<?php echo "<li" . (($this->id == "seliste") ? " class='active'>" : ">") . CHtml::link('<span class="glyphicon glyphicon-list"></span> Sélistes',array('seliste/liste')) . "</li>";?>
						<?php } ?>
						<?php if (Yii::app()->user->admin_grain) {?>
						<li class="dropdown<?php if ($this->id == "grain") echo " active";?>">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown">Grains <b class="caret"></b></a>
							<ul class="dropdown-menu">
								<?php
								echo "<li" . (($this->route == "grain/create") ? " class='active'>" : ">") . CHtml::link('<span class="glyphicon glyphicon-plus-sign"></span> Ajouter un grain',array('grain/create')) . "</li>";
								echo "<li" . (($this->route == "grain/admin") ? " class='active'>" : ">") . CHtml::link('<span class="glyphicon glyphicon-list"></span> Liste des grains',array('grain/admin')) . "</li>";
								?>
							</ul>
						</li>
						<?php } ?>
						<li class="dropdown<?php if ($this->id == "demande") echo " active";?>">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown">Demandes <b class="caret"></b></a>
							<ul class="dropdown-menu">
								<?php
								echo "<li" . (($this->route == "demande/create") ? " class='active'>" : ">") . CHtml::link('<span class="glyphicon glyphicon-plus-sign"></span> Faire une demande',array('demande/create')) . "</li>";
								if (Yii::app()->user->admin_echange) {
									echo "<li" . (($this->route == "demande/admin") ? " class='active'>" : ">") . CHtml::link('<span class="glyphicon glyphicon-list"></span> Liste des demandes',array('demande/admin')) . "</li>";
								} else {
									echo "<li" . (($this->route == "demande/liste") ? " class='active'>" : ">") . CHtml::link('<span class="glyphicon glyphicon-list"></span> Liste des demandes',array('demande/liste')) . "</li>";
								}
								?>
							</ul>
						</li>
						<?php } ?>
						<?php if (!Yii::app()->user->isGuest) {?>
						<?php if (Yii::app()->user->admin) {?>
						<li class="dropdown<?php if ($this->id == "domaine") echo " active";?>">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown">Domaines <b class="caret"></b></a>
							<ul class="dropdown-menu">
								<?php
								echo "<li" . (($this->route == "domaine/create") ? " class='active'>" : ">") . CHtml::link('<span class="glyphicon glyphicon-plus-sign"></span> Ajouter un domaine',array('domaine/create')) . "</li>";
								echo "<li" . (($this->route == "domaine/admin") ? " class='active'>" : ">") . CHtml::link('<span class="glyphicon glyphicon-list"></span> Liste des domaines',array('domaine/admin')) . "</li>";
								?>
							</ul>
						</li>
						<li class="dropdown<?php if ($this->id == "type") echo " active";?>">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown">Types <b class="caret"></b></a>
							<ul class="dropdown-menu">
								<?php
								echo "<li" . (($this->route == "type/create") ? " class='active'>" : ">") . CHtml::link('<span class="glyphicon glyphicon-plus-sign"></span> Ajouter un type',array('type/create')) . "</li>";
								echo "<li" . (($this->route == "type/admin") ? " class='active'>" : ">") . CHtml::link('<span class="glyphicon glyphicon-list"></span> Liste des types',array('type/admin')) . "</li>";
								?>
							</ul>
						</li>
						<li class="dropdown<?php if ($this->id == "groupe") echo " active";?>">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown">Groupes <b class="caret"></b></a>
							<ul class="dropdown-menu">
								<?php
								echo "<li" . (($this->route == "groupe/create") ? " class='active'>" : ">") . CHtml::link('<span class="glyphicon glyphicon-plus-sign"></span> Ajouter un groupe',array('groupe/create')) . "</li>";
								echo "<li" . (($this->route == "groupe/admin") ? " class='active'>" : ">") . CHtml::link('<span class="glyphicon glyphicon-list"></span> Liste des groupes',array('groupe/admin')) . "</li>";
								?>
							</ul>
						</li>
						<?php echo "<li" . (($this->route == "histoAdmin/admin") ? " class='active'>" : ">") . CHtml::link('Historique',array('histoAdmin/admin')) . "</li>";?>
						<?php } ?>
						<?php } ?>
						
				</ul>
				<ul class="nav navbar-nav navbar-right">
					<?php if (!Yii::app()->user->isGuest) {?>
					<?php
					$unread = '';
					$nbunread = Seliste::model()->getNbUnread(); 
					if ($nbunread) $unread = '<span class="badge">' . $nbunread . '</span>';
					$actions_mail = array("seliste/mailbox","seliste/mail","seliste/newmail","seliste/smail","seliste/sentmail");
					echo "<li";
					if (in_array($this->route,$actions_mail)) echo " class=\"active\"";
					echo ">" . CHtml::link('<span class="glyphicon glyphicon-envelope"></span> '.$unread,array('seliste/mailbox')) . "</li>";
					?>
					<?php 
					$actions_compte = array("seliste/compte","seliste/update_compte","seliste/update_compte_pass","seliste/update_compte_grains","offre/compte","demande/compte","echange/compte");
					echo "<li class=\"dropdown";
					if (in_array($this->route,$actions_compte)) echo " active";
					echo "\"\>";
					?>
						<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-user"></span> <b class="caret"></b></a>
						<ul class="dropdown-menu">
							<?php
							echo "<li" . (($this->route == "seliste/compte") ? " class='active'>" : ">") . CHtml::link('Mon compte',array('seliste/compte')) . "</li>";
							$offres = '';
							$nboffres = Offre::model()->getNbOffres();
							if ($nboffres) $offres = ' <span class="badge pull-right">' . $nboffres . '</span>';
							echo "<li" . (($this->route == "offre/compte") ? " class='active'>" : ">") . CHtml::link('Mes offres'.$offres,array('offre/compte')) . "</li>";
							$demandes = '';
							$nbdemandes = Demande::model()->getNbDemandes();
							if ($nbdemandes) $demandes = ' <span class="badge pull-right">' . $nbdemandes . '</span>';
							echo "<li" . (($this->route == "demande/compte") ? " class='active'>" : ">") . CHtml::link('Mes demandes'.$demandes,array('demande/compte')) . "</li>";
							echo "<li" . (($this->route == "echange/compte") ? " class='active'>" : ">") . CHtml::link('Mes échanges',array('echange/compte')) . "</li>";
							echo "<li>" . CHtml::link('Déconnexion ('.Yii::app()->user->name.')',array('site/logout')) . "</li>";
							?>
						</ul>
					</li>
					<li class="dropdown">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown">Themes <b class="caret"></b></a>
						<ul class="dropdown-menu">
							<?php
							echo "<li" . (($this->skin == "") ? " class='active'>" : ">") . CHtml::link('par défaut',array('site/skin','id'=>'')) . "</li>";
							?><li class="divider"></li><?php
							echo "<li" . (($this->skin == "amelia") ? " class='active'>" : ">") . CHtml::link('amelia',array('site/skin','id'=>'amelia')) . "</li>";
							echo "<li" . (($this->skin == "cerulean") ? " class='active'>" : ">") . CHtml::link('cerulean',array('site/skin','id'=>'cerulean')) . "</li>";
							echo "<li" . (($this->skin == "cosmo") ? " class='active'>" : ">") . CHtml::link('cosmo',array('site/skin','id'=>'cosmo')) . "</li>";
							echo "<li" . (($this->skin == "cyborg") ? " class='active'>" : ">") . CHtml::link('cyborg',array('site/skin','id'=>'cyborg')) . "</li>";
							echo "<li" . (($this->skin == "darkly") ? " class='active'>" : ">") . CHtml::link('darkly',array('site/skin','id'=>'darkly')) . "</li>";
							echo "<li" . (($this->skin == "flatly") ? " class='active'>" : ">") . CHtml::link('flatly',array('site/skin','id'=>'flatly')) . "</li>";
							echo "<li" . (($this->skin == "lumen") ? " class='active'>" : ">") . CHtml::link('lumen',array('site/skin','id'=>'lumen')) . "</li>";
							echo "<li" . (($this->skin == "journal") ? " class='active'>" : ">") . CHtml::link('journal',array('site/skin','id'=>'journal')) . "</li>";
							echo "<li" . (($this->skin == "readable") ? " class='active'>" : ">") . CHtml::link('readable',array('site/skin','id'=>'readable')) . "</li>";
							echo "<li" . (($this->skin == "simplex") ? " class='active'>" : ">") . CHtml::link('simplex',array('site/skin','id'=>'simplex')) . "</li>";
							echo "<li" . (($this->skin == "slate") ? " class='active'>" : ">") . CHtml::link('slate',array('site/skin','id'=>'slate')) . "</li>";
							echo "<li" . (($this->skin == "spacelab") ? " class='active'>" : ">") . CHtml::link('spacelab',array('site/skin','id'=>'spacelab')) . "</li>";
							echo "<li" . (($this->skin == "superhero") ? " class='active'>" : ">") . CHtml::link('superhero',array('site/skin','id'=>'superhero')) . "</li>";
							echo "<li" . (($this->skin == "united") ? " class='active'>" : ">") . CHtml::link('united',array('site/skin','id'=>'united')) . "</li>";
							echo "<li" . (($this->skin == "yeti") ? " class='active'>" : ">") . CHtml::link('yeti',array('site/skin','id'=>'yeti')) . "</li>";
							?>
						</ul>
					</li>
					<?php } ?>	
				</ul>
			</div><!-- /.navbar-collapse -->
		</dir>
	</nav>
				
	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<?php echo $content;?>
			</div>
		</div>
	</div>
		
	<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
	<?php 
	$cs = Yii::app()->getClientScript();
	$cs->registerCoreScript('jquery');
	?>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/bootstrap.min.js"></script>
	<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/bootstrap-datepicker.js"></script>
	<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/locales/bootstrap-datepicker.fr.js" charset="UTF-8"></script>
	<?php 
	if ($this->route <> "seliste/update_grains") {
	?>
	<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/admin.js"></script>
	<?php 
	}
	?>
</body>
</html>